package com.pz.gulimall.common.to;

import lombok.Data;
import lombok.ToString;

import javax.validation.constraints.*;
import java.util.List;

/**
 * 提交的订单数据
 */
@Data
public class OrderInfoTo {
    @NotNull(message = "orderToken不可为空")
    private String orderToken;
    @NotNull(message = "用户ID不可为空")
    private Long memberId;
    private Long couponId;
    private String memberUsername;
    @NotNull(message = "付款方式不可为空")
    private Integer payType;
    @NotNull(message = "订单来源不可为空")
    private Integer sourceType;
    private Integer billType;
    private String billHeader;
    private String billContent;
    private String billReceiverPhone;
    private String billReceiverEmail;
    @NotBlank(message = "收件人必须提交")
    private String receiverName;
    @NotBlank(message = "收件电话必须提交")
    @Pattern(regexp = "\\d{3}\\d{4}\\d{4}", message = "请提交正确的电话号码")
    private String receiverPhone;
    private String receiverPostCode;
    @NotBlank(message = "收货地址不完整")
    private String receiverProvince;
    @NotBlank(message = "收货地址不完整")
    private String receiverCity;
    @NotBlank(message = "收货地址不完整")
    private String receiverRegion;
    @NotBlank(message = "收货地址不完整")
    private String receiverDetailAddress;
    private String note;

    @NotEmpty(message = "订单的商品不可为空")
    List<OrderItem> orderItems;

    /**
     * 订单的购物项
     */
    @Data
    @ToString
    public static class OrderItem{
        @NotNull(message = "skuId不可为空")
        private Long skuId;
        @NotNull(message = "商品数量必须提交")
        @Min(value = 1, message = "商品数量必须大于1")
        private Integer count;

    }
}
